package edu.gatech.cs4400.spring2014.A8.control;


import edu.gatech.cs4400.spring2014.A8.model.PatientData;
import edu.gatech.cs4400.spring2014.A8.view.ApplicationWindow;
import edu.gatech.cs4400.spring2014.A8.view.PatientProfilePanel;

/**
 * Controller to run the patient profile editing sequence.
 * 
 * 
 * @author Stephen
 */
public class PatientProfileController implements Controller {

	/**
	 * Default run
	 */
	@Override
	public void run() {
		run(false);
	}
	
	/**
	 * Runs the profile edit menu
	 * @param needsSave true: no cancel button appears on GUI, false: cancel button available
	 */
	public void run(boolean needsSave) {
		PatientData profileData = new PatientData();
		profileData.loadData();
		PatientProfilePanel profilePanel = new PatientProfilePanel(profileData, needsSave);
		ApplicationWindow.addView(profilePanel, "profilePanel");
		ApplicationWindow.setView("profilePanel");
		Waiter.waitFor(profilePanel);
		if (profilePanel.getFeedback() == PatientProfilePanel.Feedback.SAVE) {
			profileData.saveData();
		}
	}
}
